<script type="text/javascript">
var gS={
	guidance:null,
	time:function (dp){
		var year = dp.cal.date.y;
		var month = dp.cal.date.M;
		if(this.guidance.length){
			this.guidance = $.map(this.guidance, function(g){
				return g.year == year && g.month == month ? g : null;
			});
		}else{
			this.base({"year":year,"month":month});
		}
		if(!this.guidance.length)return false;
		var area = new Array();
		$.each(this.guidance, function(index,g) {
			area.push(g.areaCode);
		});
		zcity.filter(area.toLocaleString());
		this.resetter();
	},
	areaCode:function (e){
		this.base({"year":"2017","month":"4"});
	},
	major:function(e){
		console.dir(e);
	},
	base:function (options){
		var options = options||{};
		$.ajaxSettings.async = false;
		$.post("/guidance_service/front/guidance/search.do",options,function(data){
			$.ajaxSettings.async = true;
			gS.guidance =data.data;
		});
	},
	resetter:function(options){
		console.dir(this.guidance.length);
		if(!this.guidance.length)return false;
		$("#major")[0].options.length=0;
		$("#guidance")[0].options.length=0;
		$.each(this.guidance, function(index,data){
			$("#major").append("<option value='"+data.major+"'>"+data.major+"</option>");
			$("#guidance").append("<option value='"+data.guidanceId+"'>"+data.guidanceName+"</option>");
		});
	}
};
function explains_edit(guidanceId,title,clickObj){ 
	var prompt;
	window.upClick=function(value,guidanceId){
		$(clickObj).html($(value).text().length).attr("onclick","explains_edit('"+guidanceId+"','',this)").attr("txt",value);
	};
	window.explains_txt=$(clickObj).attr("txt");
	//页面层
	layer.open({
	  title:'修改本期说明',
	  type: 2,
	  area: ['800px', '400px'], //宽高
	  skin: 'layui-layer-rim', //加上边框
	  content: "/admin/modules/guidance/base/explains.html?guidanceId="+guidanceId,
//	  btn: ['修改并保存', '取消并关闭'],
	  success: function(layero){
	   }
	});
}



function data_open(title,url,w,h){ 
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function data_edit(title,url,id,w,h){  /*zosoft-编辑*/
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function data_del(obj,id){     /*zosoft-删除*/
	layer.confirm('确认要删除吗？',function(index){
		$.post("/guidance_service/front/data/logicDelete.do",{"costId":id},function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					$(obj).parents("tr").remove();
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}

		})
	});
}


function data_shenhe(obj,costId){
	layer.confirm('审核申请？', {
		btn: ['通过','不通过','取消'],
		shade: false,
		closeBtn: 0
	},function(index){
		$.ajax({
			type:"post",
			url:"/guidance_service/front/data/update.do",
//			timeout : 0,
			data:{ costId:costId,state:1 },
			success:function(result){
				if(result.resultCode == 200){
					layer.msg("请求成功", {icon:6,time:1000},function(){
						//$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" data-id="'+$(obj).attr("data-id")+'"  onClick="article_start(this,10001)" href="javascript:;" title="开放"><i class="Hui-iconfont" style="font-size: 18px;">&#xe603;</i></a>');
						$(obj).parents("tr").find("span").removeClass().addClass("label label-success radius").text("已审核"); 
						//$(obj).remove();
						layer.close(index);
					});
				}else{
					layer.msg('操作失败', {icon:5,time:1000},function(){
						layer.close(index);
					});
				}
			}
		});
	},function(index){
		$.post("/guidance_service/front/data/update.do",{ costId:costId,state:2 },function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					$(obj).parents("tr").find("span").removeClass().addClass("label label-warning  radius").text("未通过"); 
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	});
	
};
</script> 